package com.copm.ifm.base.basic.strategy.demo;

import com.copm.ifm.base.basic.strategy.AbstractStrategyRouter;
import com.copm.ifm.base.basic.strategy.StrategyHandler;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

/**
 * @author zzf
 * @date 2021/2/2 15:30
 */
@Component
public class MyStrategyRouter extends AbstractStrategyRouter<String, Collection<?>> {

    @Override
    protected StrategyMapper<String, Collection<?>> registerStrategyMapper() {
        return new MyStrategyMapper();
    }

    public static class MyStrategyMapper implements StrategyMapper<String, Collection<?>> {

        @Override
        public StrategyHandler<String, Collection<?>> get(String param) {
            if ("1".equals(param)) {
                return param1 -> {
                    if ("2".equals(param1)) {
                        return new ArrayList<>();
                    }
                    return new HashSet<>();
                };
            }
            return StrategyHandler.DEFAULT;
        }
    }


}
